package uo.ri.ui.admin.action;

import java.util.List;
import java.util.Map;

import uo.ri.bussiness.AdminService;
import uo.ri.common.BusinessException;
import uo.ri.conf.ServicesFactory;
import alb.util.console.Console;
import alb.util.menu.Action;

public class ListMechanicsAction implements Action {
	
	@Override
	public void execute() throws BusinessException {

		Console.println("\nListado de mecánicos\n");
		AdminService adminService = ServicesFactory.getAdminService();
		List<Map<String, Object>> listado = adminService.findAllMechanics();

		for (Map<String, Object> mecanico : listado) {
			Console.printf("\t%d %s %s\n", 
					mecanico.get("id"),
					mecanico.get("nombre"), 
					mecanico.get("apellidos"));
		}

	}
}
